<html>
<head>
  <script src="sorttable.js"></script>
  <script src="sourceview.js"></script>
  <link rel="stylesheet" type="text/css" href="style.css">
  <title>zcov: /home/vagrant/workspace/proj_libjpeg/cov/rdbmp.c</title>
</head>
<body>
<center><h1> zcov: <a href="index.html">/home/vagrant/workspace/proj_libjpeg/cov</a>/<a href="rdbmp.c.html">rdbmp.c</a> </h1></center>
<hr>


<center>
<table id="headertable" cellpadding=2>
  <tr>
    <td bgcolor=#ACACFF> <b>Files:</b> </td>
    <td bgcolor=#F0F0FF> 1 </td>
    <td width="30"></td>
    <td bgcolor=#ACACFF> <b>Branches&nbsp;Taken:</b> </td>
    <td bgcolor=#F0F0FF align=right> <b>58.9%<b> </td>
    <td bgcolor=#F0F0FF align=right> 43&nbsp;/&nbsp;73 </td>
  </tr>
  <tr>
    <td bgcolor=#ACACFF> <b>Generated:</b> </td>
    <td bgcolor=#F0F0FF> 2016-04-07&nbsp;17:52 </td>
    <td width="30"></td>
    <td bgcolor=#ACACFF> <b>Branches&nbsp;Executed:</b> </td>
    <td bgcolor=#F0F0FF align=right> <b>65.8%<b> </td>
    <td bgcolor=#F0F0FF align=right> 48&nbsp;/&nbsp;73 </td>
  </tr>
  <tr>
    <td colspan=2> </td>
    <td width="30"></td>
    <td bgcolor=#ACACFF> <b>Line&nbsp;Coverage:</b> </td>
    <td bgcolor=#F0F0FF align=right> <b>51.7%</b> </td>
    <td bgcolor=#F0F0FF align=right> 92&nbsp;/&nbsp;178 </td>
  </tr>
</table>
</center>
<p>
<hr>

<center>
<table id="fileheadertable" cellpadding=2>
  <tr>
    <td bgcolor=#ACACFF> <b>Programs:</b> </td>
    <td bgcolor=#F0F0FF> 1 </td>
    <td width="30"></td>
    <td bgcolor=#ACACFF> <b>Runs</b> </td>
    <td bgcolor=#F0F0FF align=right> 5570 </td>
  </tr>
</table>
</center>
<p>
<hr>

<pre>
<span class="lineNum">       1 </span>                : <I><FONT COLOR="#B22222">/*
<span class="lineNum">       2 </span>                :  * rdbmp.c
<span class="lineNum">       3 </span>                :  *
<span class="lineNum">       4 </span>                :  * Copyright (C) 1994-1996, Thomas G. Lane.
<span class="lineNum">       5 </span>                :  * This file is part of the Independent JPEG Group's software.
<span class="lineNum">       6 </span>                :  * For conditions of distribution and use, see the accompanying README file.
<span class="lineNum">       7 </span>                :  *
<span class="lineNum">       8 </span>                :  * This file contains routines to read input images in Microsoft &quot;BMP&quot;
<span class="lineNum">       9 </span>                :  * format (MS Windows 3.x, OS/2 1.x, and OS/2 2.x flavors).
<span class="lineNum">      10 </span>                :  * Currently, only 8-bit and 24-bit images are supported, not 1-bit or
<span class="lineNum">      11 </span>                :  * 4-bit (feeding such low-depth images into JPEG would be silly anyway).
<span class="lineNum">      12 </span>                :  * Also, we don't support RLE-compressed files.
<span class="lineNum">      13 </span>                :  *
<span class="lineNum">      14 </span>                :  * These routines may need modification for non-Unix environments or
<span class="lineNum">      15 </span>                :  * specialized applications.  As they stand, they assume input from
<span class="lineNum">      16 </span>                :  * an ordinary stdio stream.  They further assume that reading begins
<span class="lineNum">      17 </span>                :  * at the start of the file; start_input may need work if the
<span class="lineNum">      18 </span>                :  * user interface has already read some data (e.g., to determine that
<span class="lineNum">      19 </span>                :  * the file is indeed BMP format).
<span class="lineNum">      20 </span>                :  *
<span class="lineNum">      21 </span>                :  * This code contributed by James Arthur Boucher.
<span class="lineNum">      22 </span>                :  */</FONT></I>
<span class="lineNum">      23 </span>                : 
<span class="lineNum">      24 </span>                : #<B><FONT COLOR="#5F9EA0">include</FONT></B> <B><FONT COLOR="#BC8F8F">&quot;cdjpeg.h&quot;</FONT></B>		<I><FONT COLOR="#B22222">/* Common decls for cjpeg/djpeg applications */</FONT></I>
<span class="lineNum">      25 </span>                : 
<span class="lineNum">      26 </span>                : #<B><FONT COLOR="#5F9EA0">ifdef</FONT></B> <FONT COLOR="#B8860B">BMP_SUPPORTED</FONT>
<span class="lineNum">      27 </span>                : 
<span class="lineNum">      28 </span>                : 
<span class="lineNum">      29 </span>                : <I><FONT COLOR="#B22222">/* Macros to deal with unsigned chars as efficiently as compiler allows */</FONT></I>
<span class="lineNum">      30 </span>                : 
<span class="lineNum">      31 </span>                : #<B><FONT COLOR="#5F9EA0">ifdef</FONT></B> <FONT COLOR="#B8860B">HAVE_UNSIGNED_CHAR</FONT>
<span class="lineNum">      32 </span>                : <B><FONT COLOR="#228B22">typedef</FONT></B> <B><FONT COLOR="#228B22">unsigned</FONT></B> <B><FONT COLOR="#228B22">char</FONT></B> U_CHAR;
<span class="lineNum">      33 </span>                : #<B><FONT COLOR="#5F9EA0">define</FONT></B> <B><FONT COLOR="#0000FF">UCH</FONT></B>(x)	((int) (x))
<span class="lineNum">      34 </span>                : #<B><FONT COLOR="#5F9EA0">else</FONT></B> <I><FONT COLOR="#B22222">/* !HAVE_UNSIGNED_CHAR */</FONT></I>
<span class="lineNum">      35 </span>                : #<B><FONT COLOR="#5F9EA0">ifdef</FONT></B> <FONT COLOR="#B8860B">CHAR_IS_UNSIGNED</FONT>
<span class="lineNum">      36 </span>                : <B><FONT COLOR="#228B22">typedef</FONT></B> <B><FONT COLOR="#228B22">char</FONT></B> U_CHAR;
<span class="lineNum">      37 </span>                : #<B><FONT COLOR="#5F9EA0">define</FONT></B> <B><FONT COLOR="#0000FF">UCH</FONT></B>(x)	((int) (x))
<span class="lineNum">      38 </span>                : #<B><FONT COLOR="#5F9EA0">else</FONT></B>
<span class="lineNum">      39 </span>                : <B><FONT COLOR="#228B22">typedef</FONT></B> <B><FONT COLOR="#228B22">char</FONT></B> U_CHAR;
<span class="lineNum">      40 </span>                : #<B><FONT COLOR="#5F9EA0">define</FONT></B> <B><FONT COLOR="#0000FF">UCH</FONT></B>(x)	((int) (x) &amp; 0xFF)
<span class="lineNum">      41 </span>                : #<B><FONT COLOR="#5F9EA0">endif</FONT></B>
<span class="lineNum">      42 </span>                : #<B><FONT COLOR="#5F9EA0">endif</FONT></B> <I><FONT COLOR="#B22222">/* HAVE_UNSIGNED_CHAR */</FONT></I>
<span class="lineNum">      43 </span>                : 
<span class="lineNum">      44 </span>                : 
<span class="lineNum">      45 </span>                : #<B><FONT COLOR="#5F9EA0">define</FONT></B>	<B><FONT COLOR="#0000FF">ReadOK</FONT></B>(file,buffer,len)	(JFREAD(file,buffer,len) == ((size_t) (len)))
<span class="lineNum">      46 </span>                : 
<span class="lineNum">      47 </span>                : 
<span class="lineNum">      48 </span>                : <I><FONT COLOR="#B22222">/* Private version of data source object */</FONT></I>
<span class="lineNum">      49 </span>                : 
<span class="lineNum">      50 </span>                : <B><FONT COLOR="#228B22">typedef</FONT></B> <B><FONT COLOR="#228B22">struct</FONT></B> _bmp_source_struct * bmp_source_ptr;
<span class="lineNum">      51 </span>                : 
<span class="lineNum">      52 </span>                : <B><FONT COLOR="#228B22">typedef</FONT></B> <B><FONT COLOR="#228B22">struct</FONT></B> _bmp_source_struct {
<span class="lineNum">      53 </span>                :   <B><FONT COLOR="#228B22">struct</FONT></B> cjpeg_source_struct pub; <I><FONT COLOR="#B22222">/* public fields */</FONT></I>
<span class="lineNum">      54 </span>                : 
<span class="lineNum">      55 </span>                :   j_compress_ptr cinfo;		<I><FONT COLOR="#B22222">/* back link saves passing separate parm */</FONT></I>
<span class="lineNum">      56 </span>                : 
<span class="lineNum">      57 </span>                :   JSAMPARRAY colormap;		<I><FONT COLOR="#B22222">/* BMP colormap (converted to my format) */</FONT></I>
<span class="lineNum">      58 </span>                : 
<span class="lineNum">      59 </span>                :   jvirt_sarray_ptr whole_image;	<I><FONT COLOR="#B22222">/* Needed to reverse row order */</FONT></I>
<span class="lineNum">      60 </span>                :   JDIMENSION source_row;	<I><FONT COLOR="#B22222">/* Current source row number */</FONT></I>
<span class="lineNum">      61 </span>                :   JDIMENSION row_width;		<I><FONT COLOR="#B22222">/* Physical width of scanlines in file */</FONT></I>
<span class="lineNum">      62 </span>                : 
<span class="lineNum">      63 </span>                :   <B><FONT COLOR="#228B22">int</FONT></B> bits_per_pixel;		<I><FONT COLOR="#B22222">/* remembers 8- or 24-bit format */</FONT></I>
<span class="lineNum">      64 </span>                : } bmp_source_struct;
<span class="lineNum">      65 </span>                : 
<span class="lineNum">      66 </span>                : 
<span class="lineNum">      67 </span>                : <B><FONT COLOR="#0000FF">LOCAL</FONT></B>(<B><FONT COLOR="#228B22">int</FONT></B>)
<span class="lineNum">      68 </span><span class="lineCov">            8580: <B><FONT COLOR="#0000FF">read_byte</FONT></B> (bmp_source_ptr sinfo)</span>
<span class="lineNum">      69 </span>                : <I><FONT COLOR="#B22222">/* Read next byte from BMP file */</FONT></I>
<span class="lineNum">      70 </span>                : {
<span class="lineNum">      71 </span><span class="lineCov">            8580:   <B><FONT COLOR="#228B22">register</FONT></B> FILE *infile = sinfo-&gt;pub.input_file;</span>
<span class="lineNum">      72 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> <B><FONT COLOR="#228B22">int</FONT></B> c;
<span class="lineNum">      73 </span>                : 
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">             282: branch 1 taken</span>
<span class="lineNum">         </span><span class="branchTaken">            8298: branch 2 taken</span>
</span><span class="lineNum">      74 </span><span class="lineCov">            8580:   <B><FONT COLOR="#A020F0">if</FONT></B> ((c = getc(infile)) == EOF)</span>
<span class="lineNum">      75 </span><span class="lineCov">             282:     ERREXIT(sinfo-&gt;cinfo, JERR_INPUT_EOF);</span>
<span class="lineNum">      76 </span><span class="lineCov">            8298:   <B><FONT COLOR="#A020F0">return</FONT></B> c;</span>
<span class="lineNum">      77 </span>                : }
<span class="lineNum">      78 </span>                : 
<span class="lineNum">      79 </span>                : 
<span class="lineNum">      80 </span>                : <B><FONT COLOR="#0000FF">LOCAL</FONT></B>(<B><FONT COLOR="#228B22">void</FONT></B>)
<span class="lineNum">      81 </span><span class="lineCov">             152: <B><FONT COLOR="#0000FF">read_colormap</FONT></B> (bmp_source_ptr sinfo, <B><FONT COLOR="#228B22">int</FONT></B> cmaplen, <B><FONT COLOR="#228B22">int</FONT></B> mapentrysize)</span>
<span class="lineNum">      82 </span>                : <I><FONT COLOR="#B22222">/* Read the colormap from a BMP file */</FONT></I>
<span class="lineNum">      83 </span>                : {
<span class="lineNum">      84 </span>                :   <B><FONT COLOR="#228B22">int</FONT></B> i;
<span class="lineNum">      85 </span>                : 
<span class="branchGroup"><span class="lineNum">         </span><span class="branchNotTaken">               0: branch 0 not taken</span>
<span class="lineNum">         </span><span class="branchTaken">             152: branch 1 taken</span>
<span class="lineNum">         </span><span class="branchNotTaken">               0: branch 2 not taken</span>
</span><span class="lineNum">      86 </span><span class="lineCov">             152:   <B><FONT COLOR="#A020F0">switch</FONT></B> (mapentrysize) {</span>
<span class="lineNum">      87 </span>                :   <B><FONT COLOR="#A020F0">case</FONT></B> <B><FONT COLOR="#5F9EA0">3</FONT></B>:
<span class="lineNum">      88 </span>                :     <I><FONT COLOR="#B22222">/* BGR format (occurs in OS/2 files) */</FONT></I>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchNotTaken">               0: branch 0 not taken</span>
<span class="lineNum">         </span><span class="branchNotTaken">               0: branch 1 not taken</span>
</span><span class="lineNum">      89 </span><span class="lineNoCov">               0:     <B><FONT COLOR="#A020F0">for</FONT></B> (i = 0; i &lt; cmaplen; i++) {</span>
<span class="lineNum">      90 </span><span class="lineNoCov">               0:       sinfo-&gt;colormap[2][i] = (JSAMPLE) read_byte(sinfo);</span>
<span class="lineNum">      91 </span><span class="lineNoCov">               0:       sinfo-&gt;colormap[1][i] = (JSAMPLE) read_byte(sinfo);</span>
<span class="lineNum">      92 </span><span class="lineNoCov">               0:       sinfo-&gt;colormap[0][i] = (JSAMPLE) read_byte(sinfo);</span>
<span class="lineNum">      93 </span>                :     }
<span class="lineNum">      94 </span><span class="lineNoCov">               0:     <B><FONT COLOR="#A020F0">break</FONT></B>;</span>
<span class="lineNum">      95 </span>                :   <B><FONT COLOR="#A020F0">case</FONT></B> <B><FONT COLOR="#5F9EA0">4</FONT></B>:
<span class="lineNum">      96 </span>                :     <I><FONT COLOR="#B22222">/* BGR0 format (occurs in MS Windows files) */</FONT></I>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">            1314: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">              14: branch 1 taken</span>
</span><span class="lineNum">      97 </span><span class="lineCov">            1328:     <B><FONT COLOR="#A020F0">for</FONT></B> (i = 0; i &lt; cmaplen; i++) {</span>
<span class="lineNum">      98 </span><span class="lineCov">            1314:       sinfo-&gt;colormap[2][i] = (JSAMPLE) read_byte(sinfo);</span>
<span class="lineNum">      99 </span><span class="lineCov">            1299:       sinfo-&gt;colormap[1][i] = (JSAMPLE) read_byte(sinfo);</span>
<span class="lineNum">     100 </span><span class="lineCov">            1241:       sinfo-&gt;colormap[0][i] = (JSAMPLE) read_byte(sinfo);</span>
<span class="lineNum">     101 </span><span class="lineCov">            1202:       (<B><FONT COLOR="#228B22">void</FONT></B>) read_byte(sinfo);</span>
<span class="lineNum">     102 </span>                :     }
<span class="lineNum">     103 </span><span class="lineCov">              14:     <B><FONT COLOR="#A020F0">break</FONT></B>;</span>
<span class="lineNum">     104 </span>                :   <B><FONT COLOR="#5F9EA0">default</FONT></B>:
<span class="lineNum">     105 </span><span class="lineNoCov">               0:     ERREXIT(sinfo-&gt;cinfo, JERR_BMP_BADCMAP);</span>
<span class="lineNum">     106 </span><span class="lineNoCov">               0:     <B><FONT COLOR="#A020F0">break</FONT></B>;</span>
<span class="lineNum">     107 </span>                :   }
<span class="lineNum">     108 </span><span class="lineCov">              14: }</span>
<span class="lineNum">     109 </span>                : 
<span class="lineNum">     110 </span>                : 
<span class="lineNum">     111 </span>                : <I><FONT COLOR="#B22222">/*
<span class="lineNum">     112 </span>                :  * Read one row of pixels.
<span class="lineNum">     113 </span>                :  * The image has been read into the whole_image array, but is otherwise
<span class="lineNum">     114 </span>                :  * unprocessed.  We must read it out in top-to-bottom row order, and if
<span class="lineNum">     115 </span>                :  * it is an 8-bit image, we must expand colormapped pixels to 24bit format.
<span class="lineNum">     116 </span>                :  */</FONT></I>
<span class="lineNum">     117 </span>                : 
<span class="lineNum">     118 </span>                : <B><FONT COLOR="#0000FF">METHODDEF</FONT></B>(JDIMENSION)
<span class="lineNum">     119 </span><span class="lineNoCov">               0: <B><FONT COLOR="#0000FF">get_8bit_row</FONT></B> (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)</span>
<span class="lineNum">     120 </span>                : <I><FONT COLOR="#B22222">/* This version is for reading 8-bit colormap indexes */</FONT></I>
<span class="lineNum">     121 </span>                : {
<span class="lineNum">     122 </span><span class="lineNoCov">               0:   bmp_source_ptr source = (bmp_source_ptr) sinfo;</span>
<span class="lineNum">     123 </span><span class="lineNoCov">               0:   <B><FONT COLOR="#228B22">register</FONT></B> JSAMPARRAY colormap = source-&gt;colormap;</span>
<span class="lineNum">     124 </span>                :   JSAMPARRAY image_ptr;
<span class="lineNum">     125 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> <B><FONT COLOR="#228B22">int</FONT></B> t;
<span class="lineNum">     126 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> JSAMPROW inptr, outptr;
<span class="lineNum">     127 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> JDIMENSION col;
<span class="lineNum">     128 </span>                : 
<span class="lineNum">     129 </span>                :   <I><FONT COLOR="#B22222">/* Fetch next row from virtual array */</FONT></I>
<span class="lineNum">     130 </span><span class="lineNoCov">               0:   source-&gt;source_row--;</span>
<span class="lineNum">     131 </span><span class="lineNoCov">               0:   image_ptr = (*cinfo-&gt;mem-&gt;access_virt_sarray)</span>
<span class="lineNum">     132 </span><span class="lineNoCov">               0:     ((j_common_ptr) cinfo, source-&gt;whole_image,</span>
<span class="lineNum">     133 </span>                :      source-&gt;source_row, (JDIMENSION) 1, FALSE);
<span class="lineNum">     134 </span>                : 
<span class="lineNum">     135 </span>                :   <I><FONT COLOR="#B22222">/* Expand the colormap indexes to real data */</FONT></I>
<span class="lineNum">     136 </span><span class="lineNoCov">               0:   inptr = image_ptr[0];</span>
<span class="lineNum">     137 </span><span class="lineNoCov">               0:   outptr = source-&gt;pub.buffer[0];</span>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchNotTaken">               0: branch 0 not taken</span>
<span class="lineNum">         </span><span class="branchNotTaken">               0: branch 1 not taken</span>
</span><span class="lineNum">     138 </span><span class="lineNoCov">               0:   <B><FONT COLOR="#A020F0">for</FONT></B> (col = cinfo-&gt;image_width; col &gt; 0; col--) {</span>
<span class="lineNum">     139 </span><span class="lineNoCov">               0:     t = GETJSAMPLE(*inptr++);</span>
<span class="lineNum">     140 </span><span class="lineNoCov">               0:     *outptr++ = colormap[0][t];	<I><FONT COLOR="#B22222">/* can omit GETJSAMPLE() safely */</FONT></I></span>
<span class="lineNum">     141 </span><span class="lineNoCov">               0:     *outptr++ = colormap[1][t];</span>
<span class="lineNum">     142 </span><span class="lineNoCov">               0:     *outptr++ = colormap[2][t];</span>
<span class="lineNum">     143 </span>                :   }
<span class="lineNum">     144 </span>                : 
<span class="lineNum">     145 </span><span class="lineNoCov">               0:   <B><FONT COLOR="#A020F0">return</FONT></B> 1;</span>
<span class="lineNum">     146 </span>                : }
<span class="lineNum">     147 </span>                : 
<span class="lineNum">     148 </span>                : 
<span class="lineNum">     149 </span>                : <B><FONT COLOR="#0000FF">METHODDEF</FONT></B>(JDIMENSION)
<span class="lineNum">     150 </span><span class="lineNoCov">               0: <B><FONT COLOR="#0000FF">get_24bit_row</FONT></B> (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)</span>
<span class="lineNum">     151 </span>                : <I><FONT COLOR="#B22222">/* This version is for reading 24-bit pixels */</FONT></I>
<span class="lineNum">     152 </span>                : {
<span class="lineNum">     153 </span><span class="lineNoCov">               0:   bmp_source_ptr source = (bmp_source_ptr) sinfo;</span>
<span class="lineNum">     154 </span>                :   JSAMPARRAY image_ptr;
<span class="lineNum">     155 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> JSAMPROW inptr, outptr;
<span class="lineNum">     156 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> JDIMENSION col;
<span class="lineNum">     157 </span>                : 
<span class="lineNum">     158 </span>                :   <I><FONT COLOR="#B22222">/* Fetch next row from virtual array */</FONT></I>
<span class="lineNum">     159 </span><span class="lineNoCov">               0:   source-&gt;source_row--;</span>
<span class="lineNum">     160 </span><span class="lineNoCov">               0:   image_ptr = (*cinfo-&gt;mem-&gt;access_virt_sarray)</span>
<span class="lineNum">     161 </span><span class="lineNoCov">               0:     ((j_common_ptr) cinfo, source-&gt;whole_image,</span>
<span class="lineNum">     162 </span>                :      source-&gt;source_row, (JDIMENSION) 1, FALSE);
<span class="lineNum">     163 </span>                : 
<span class="lineNum">     164 </span>                :   <I><FONT COLOR="#B22222">/* Transfer data.  Note source values are in BGR order
<span class="lineNum">     165 </span>                :    * (even though Microsoft's own documents say the opposite).
<span class="lineNum">     166 </span>                :    */</FONT></I>
<span class="lineNum">     167 </span><span class="lineNoCov">               0:   inptr = image_ptr[0];</span>
<span class="lineNum">     168 </span><span class="lineNoCov">               0:   outptr = source-&gt;pub.buffer[0];</span>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchNotTaken">               0: branch 0 not taken</span>
<span class="lineNum">         </span><span class="branchNotTaken">               0: branch 1 not taken</span>
</span><span class="lineNum">     169 </span><span class="lineNoCov">               0:   <B><FONT COLOR="#A020F0">for</FONT></B> (col = cinfo-&gt;image_width; col &gt; 0; col--) {</span>
<span class="lineNum">     170 </span><span class="lineNoCov">               0:     outptr[2] = *inptr++;	<I><FONT COLOR="#B22222">/* can omit GETJSAMPLE() safely */</FONT></I></span>
<span class="lineNum">     171 </span><span class="lineNoCov">               0:     outptr[1] = *inptr++;</span>
<span class="lineNum">     172 </span><span class="lineNoCov">               0:     outptr[0] = *inptr++;</span>
<span class="lineNum">     173 </span><span class="lineNoCov">               0:     outptr += 3;</span>
<span class="lineNum">     174 </span>                :   }
<span class="lineNum">     175 </span>                : 
<span class="lineNum">     176 </span><span class="lineNoCov">               0:   <B><FONT COLOR="#A020F0">return</FONT></B> 1;</span>
<span class="lineNum">     177 </span>                : }
<span class="lineNum">     178 </span>                : 
<span class="lineNum">     179 </span>                : 
<span class="lineNum">     180 </span>                : <I><FONT COLOR="#B22222">/*
<span class="lineNum">     181 </span>                :  * This method loads the image into whole_image during the first call on
<span class="lineNum">     182 </span>                :  * get_pixel_rows.  The get_pixel_rows pointer is then adjusted to call
<span class="lineNum">     183 </span>                :  * get_8bit_row or get_24bit_row on subsequent calls.
<span class="lineNum">     184 </span>                :  */</FONT></I>
<span class="lineNum">     185 </span>                : 
<span class="lineNum">     186 </span>                : <B><FONT COLOR="#0000FF">METHODDEF</FONT></B>(JDIMENSION)
<span class="lineNum">     187 </span><span class="lineNoCov">               0: <B><FONT COLOR="#0000FF">preload_image</FONT></B> (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)</span>
<span class="lineNum">     188 </span>                : {
<span class="lineNum">     189 </span><span class="lineNoCov">               0:   bmp_source_ptr source = (bmp_source_ptr) sinfo;</span>
<span class="lineNum">     190 </span><span class="lineNoCov">               0:   <B><FONT COLOR="#228B22">register</FONT></B> FILE *infile = source-&gt;pub.input_file;</span>
<span class="lineNum">     191 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> <B><FONT COLOR="#228B22">int</FONT></B> c;
<span class="lineNum">     192 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> JSAMPROW out_ptr;
<span class="lineNum">     193 </span>                :   JSAMPARRAY image_ptr;
<span class="lineNum">     194 </span>                :   JDIMENSION row, col;
<span class="lineNum">     195 </span><span class="lineNoCov">               0:   cd_progress_ptr progress = (cd_progress_ptr) cinfo-&gt;progress;</span>
<span class="lineNum">     196 </span>                : 
<span class="lineNum">     197 </span>                :   <I><FONT COLOR="#B22222">/* Read the data into a virtual array in input-file row order. */</FONT></I>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchNotTaken">               0: branch 0 not taken</span>
<span class="lineNum">         </span><span class="branchNotTaken">               0: branch 1 not taken</span>
</span><span class="lineNum">     198 </span><span class="lineNoCov">               0:   <B><FONT COLOR="#A020F0">for</FONT></B> (row = 0; row &lt; cinfo-&gt;image_height; row++) {</span>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchNotTaken">               0: branch 0 not taken</span>
<span class="lineNum">         </span><span class="branchNotTaken">               0: branch 1 not taken</span>
</span><span class="lineNum">     199 </span><span class="lineNoCov">               0:     <B><FONT COLOR="#A020F0">if</FONT></B> (progress != NULL) {</span>
<span class="lineNum">     200 </span><span class="lineNoCov">               0:       progress-&gt;pub.pass_counter = (<B><FONT COLOR="#228B22">long</FONT></B>) row;</span>
<span class="lineNum">     201 </span><span class="lineNoCov">               0:       progress-&gt;pub.pass_limit = (<B><FONT COLOR="#228B22">long</FONT></B>) cinfo-&gt;image_height;</span>
<span class="lineNum">     202 </span><span class="lineNoCov">               0:       (*progress-&gt;pub.progress_monitor) ((j_common_ptr) cinfo);</span>
<span class="lineNum">     203 </span>                :     }
<span class="lineNum">     204 </span><span class="lineNoCov">               0:     image_ptr = (*cinfo-&gt;mem-&gt;access_virt_sarray)</span>
<span class="lineNum">     205 </span><span class="lineNoCov">               0:       ((j_common_ptr) cinfo, source-&gt;whole_image,</span>
<span class="lineNum">     206 </span>                :        row, (JDIMENSION) 1, TRUE);
<span class="lineNum">     207 </span><span class="lineNoCov">               0:     out_ptr = image_ptr[0];</span>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchNotTaken">               0: branch 0 not taken</span>
<span class="lineNum">         </span><span class="branchNotTaken">               0: branch 1 not taken</span>
</span><span class="lineNum">     208 </span><span class="lineNoCov">               0:     <B><FONT COLOR="#A020F0">for</FONT></B> (col = source-&gt;row_width; col &gt; 0; col--) {</span>
<span class="lineNum">     209 </span>                :       <I><FONT COLOR="#B22222">/* inline copy of read_byte() for speed */</FONT></I>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchNotTaken">               0: branch 1 not taken</span>
<span class="lineNum">         </span><span class="branchNotTaken">               0: branch 2 not taken</span>
</span><span class="lineNum">     210 </span><span class="lineNoCov">               0:       <B><FONT COLOR="#A020F0">if</FONT></B> ((c = getc(infile)) == EOF)</span>
<span class="lineNum">     211 </span><span class="lineNoCov">               0: 	ERREXIT(cinfo, JERR_INPUT_EOF);</span>
<span class="lineNum">     212 </span><span class="lineNoCov">               0:       *out_ptr++ = (JSAMPLE) c;</span>
<span class="lineNum">     213 </span>                :     }
<span class="lineNum">     214 </span>                :   }
<span class="branchGroup"><span class="lineNum">         </span><span class="branchNotTaken">               0: branch 0 not taken</span>
<span class="lineNum">         </span><span class="branchNotTaken">               0: branch 1 not taken</span>
</span><span class="lineNum">     215 </span><span class="lineNoCov">               0:   <B><FONT COLOR="#A020F0">if</FONT></B> (progress != NULL)</span>
<span class="lineNum">     216 </span><span class="lineNoCov">               0:     progress-&gt;completed_extra_passes++;</span>
<span class="lineNum">     217 </span>                : 
<span class="lineNum">     218 </span>                :   <I><FONT COLOR="#B22222">/* Set up to read from the virtual array in top-to-bottom order */</FONT></I>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchNotTaken">               0: branch 0 not taken</span>
<span class="lineNum">         </span><span class="branchNotTaken">               0: branch 1 not taken</span>
<span class="lineNum">         </span><span class="branchNotTaken">               0: branch 2 not taken</span>
</span><span class="lineNum">     219 </span><span class="lineNoCov">               0:   <B><FONT COLOR="#A020F0">switch</FONT></B> (source-&gt;bits_per_pixel) {</span>
<span class="lineNum">     220 </span>                :   <B><FONT COLOR="#A020F0">case</FONT></B> <B><FONT COLOR="#5F9EA0">8</FONT></B>:
<span class="lineNum">     221 </span><span class="lineNoCov">               0:     source-&gt;pub.get_pixel_rows = get_8bit_row;</span>
<span class="lineNum">     222 </span><span class="lineNoCov">               0:     <B><FONT COLOR="#A020F0">break</FONT></B>;</span>
<span class="lineNum">     223 </span>                :   <B><FONT COLOR="#A020F0">case</FONT></B> <B><FONT COLOR="#5F9EA0">24</FONT></B>:
<span class="lineNum">     224 </span><span class="lineNoCov">               0:     source-&gt;pub.get_pixel_rows = get_24bit_row;</span>
<span class="lineNum">     225 </span><span class="lineNoCov">               0:     <B><FONT COLOR="#A020F0">break</FONT></B>;</span>
<span class="lineNum">     226 </span>                :   <B><FONT COLOR="#5F9EA0">default</FONT></B>:
<span class="lineNum">     227 </span><span class="lineNoCov">               0:     ERREXIT(cinfo, JERR_BMP_BADDEPTH);</span>
<span class="lineNum">     228 </span>                :   }
<span class="lineNum">     229 </span><span class="lineNoCov">               0:   source-&gt;source_row = cinfo-&gt;image_height;</span>
<span class="lineNum">     230 </span>                : 
<span class="lineNum">     231 </span>                :   <I><FONT COLOR="#B22222">/* And read the first row */</FONT></I>
<span class="lineNum">     232 </span><span class="lineNoCov">               0:   <B><FONT COLOR="#A020F0">return</FONT></B> (*source-&gt;pub.get_pixel_rows) (cinfo, sinfo);</span>
<span class="lineNum">     233 </span>                : }
<span class="lineNum">     234 </span>                : 
<span class="lineNum">     235 </span>                : 
<span class="lineNum">     236 </span>                : <I><FONT COLOR="#B22222">/*
<span class="lineNum">     237 </span>                :  * Read the file header; return image size and component count.
<span class="lineNum">     238 </span>                :  */</FONT></I>
<span class="lineNum">     239 </span>                : 
<span class="lineNum">     240 </span>                : <B><FONT COLOR="#0000FF">METHODDEF</FONT></B>(<B><FONT COLOR="#228B22">void</FONT></B>)
<span class="lineNum">     241 </span><span class="lineCov">             506: <B><FONT COLOR="#0000FF">start_input_bmp</FONT></B> (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)</span>
<span class="lineNum">     242 </span>                : {
<span class="lineNum">     243 </span><span class="lineCov">             506:   bmp_source_ptr source = (bmp_source_ptr) sinfo;</span>
<span class="lineNum">     244 </span>                :   U_CHAR bmpfileheader[14];
<span class="lineNum">     245 </span>                :   U_CHAR bmpinfoheader[64];
<span class="lineNum">     246 </span>                : #<B><FONT COLOR="#5F9EA0">define</FONT></B> <B><FONT COLOR="#0000FF">GET_2B</FONT></B>(array,offset)  ((unsigned int) UCH(array[offset]) + \
<span class="lineNum">     247 </span>                : 			       (((<B><FONT COLOR="#228B22">unsigned</FONT></B> <B><FONT COLOR="#228B22">int</FONT></B>) UCH(array[offset+1])) &lt;&lt; 8))
<span class="lineNum">     248 </span>                : #<B><FONT COLOR="#5F9EA0">define</FONT></B> <B><FONT COLOR="#0000FF">GET_4B</FONT></B>(array,offset)  ((INT32) UCH(array[offset]) + \
<span class="lineNum">     249 </span>                : 			       (((INT32) UCH(array[offset+1])) &lt;&lt; 8) + \
<span class="lineNum">     250 </span>                : 			       (((INT32) UCH(array[offset+2])) &lt;&lt; 16) + \
<span class="lineNum">     251 </span>                : 			       (((INT32) UCH(array[offset+3])) &lt;&lt; 24))
<span class="lineNum">     252 </span>                :   INT32 bfOffBits;
<span class="lineNum">     253 </span>                :   INT32 headerSize;
<span class="lineNum">     254 </span><span class="lineCov">             506:   INT32 biWidth = 0;		<I><FONT COLOR="#B22222">/* initialize to avoid compiler warning */</FONT></I></span>
<span class="lineNum">     255 </span><span class="lineCov">             506:   INT32 biHeight = 0;</span>
<span class="lineNum">     256 </span>                :   <B><FONT COLOR="#228B22">unsigned</FONT></B> <B><FONT COLOR="#228B22">int</FONT></B> biPlanes;
<span class="lineNum">     257 </span>                :   INT32 biCompression;
<span class="lineNum">     258 </span>                :   INT32 biXPelsPerMeter,biYPelsPerMeter;
<span class="lineNum">     259 </span><span class="lineCov">             506:   INT32 biClrUsed = 0;</span>
<span class="lineNum">     260 </span><span class="lineCov">             506:   <B><FONT COLOR="#228B22">int</FONT></B> mapentrysize = 0;		<I><FONT COLOR="#B22222">/* 0 indicates no colormap */</FONT></I></span>
<span class="lineNum">     261 </span>                :   INT32 bPad;
<span class="lineNum">     262 </span>                :   JDIMENSION row_width;
<span class="lineNum">     263 </span>                : 
<span class="lineNum">     264 </span>                :   <I><FONT COLOR="#B22222">/* Read and verify the bitmap file header */</FONT></I>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">              14: branch 1 taken</span>
<span class="lineNum">         </span><span class="branchTaken">             492: branch 2 taken</span>
</span><span class="lineNum">     265 </span><span class="lineCov">             506:   <B><FONT COLOR="#A020F0">if</FONT></B> (! ReadOK(source-&gt;pub.input_file, bmpfileheader, 14))</span>
<span class="lineNum">     266 </span><span class="lineCov">              14:     ERREXIT(cinfo, JERR_INPUT_EOF);</span>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">              14: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">             478: branch 1 taken</span>
</span><span class="lineNum">     267 </span><span class="lineCov">             492:   <B><FONT COLOR="#A020F0">if</FONT></B> (GET_2B(bmpfileheader,0) != 0x4D42) <I><FONT COLOR="#B22222">/* 'BM' */</FONT></I></span>
<span class="lineNum">     268 </span><span class="lineCov">              14:     ERREXIT(cinfo, JERR_BMP_NOT);</span>
<span class="lineNum">     269 </span><span class="lineCov">             478:   bfOffBits = (INT32) GET_4B(bmpfileheader,10);</span>
<span class="lineNum">     270 </span>                :   <I><FONT COLOR="#B22222">/* We ignore the remaining fileheader fields */</FONT></I>
<span class="lineNum">     271 </span>                : 
<span class="lineNum">     272 </span>                :   <I><FONT COLOR="#B22222">/* The infoheader might be 12 bytes (OS/2 1.x), 40 bytes (Windows),
<span class="lineNum">     273 </span>                :    * or 64 bytes (OS/2 2.x).  Check the first 4 bytes to find out which.
<span class="lineNum">     274 </span>                :    */</FONT></I>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">              14: branch 1 taken</span>
<span class="lineNum">         </span><span class="branchTaken">             464: branch 2 taken</span>
</span><span class="lineNum">     275 </span><span class="lineCov">             478:   <B><FONT COLOR="#A020F0">if</FONT></B> (! ReadOK(source-&gt;pub.input_file, bmpinfoheader, 4))</span>
<span class="lineNum">     276 </span><span class="lineCov">              14:     ERREXIT(cinfo, JERR_INPUT_EOF);</span>
<span class="lineNum">     277 </span><span class="lineCov">             464:   headerSize = (INT32) GET_4B(bmpinfoheader,0);</span>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">             464: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchNotTaken">               0: branch 1 not taken</span>
<span class="lineNum">         </span><span class="branchTaken">              14: branch 2 taken</span>
<span class="lineNum">         </span><span class="branchTaken">             450: branch 3 taken</span>
</span><span class="lineNum">     278 </span><span class="lineCov">             464:   <B><FONT COLOR="#A020F0">if</FONT></B> (headerSize &lt; 12 || headerSize &gt; 64)</span>
<span class="lineNum">     279 </span><span class="lineCov">              14:     ERREXIT(cinfo, JERR_BMP_BADHEADER);</span>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">              14: branch 1 taken</span>
<span class="lineNum">         </span><span class="branchTaken">             436: branch 2 taken</span>
</span><span class="lineNum">     280 </span><span class="lineCov">             450:   <B><FONT COLOR="#A020F0">if</FONT></B> (! ReadOK(source-&gt;pub.input_file, bmpinfoheader+4, headerSize-4))</span>
<span class="lineNum">     281 </span><span class="lineCov">              14:     ERREXIT(cinfo, JERR_INPUT_EOF);</span>
<span class="lineNum">     282 </span>                : 
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">              42: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">             380: branch 1 taken</span>
<span class="lineNum">         </span><span class="branchTaken">              14: branch 2 taken</span>
</span><span class="lineNum">     283 </span><span class="lineCov">             436:   <B><FONT COLOR="#A020F0">switch</FONT></B> ((<B><FONT COLOR="#228B22">int</FONT></B>) headerSize) {</span>
<span class="lineNum">     284 </span>                :   <B><FONT COLOR="#A020F0">case</FONT></B> <B><FONT COLOR="#5F9EA0">12</FONT></B>:
<span class="lineNum">     285 </span>                :     <I><FONT COLOR="#B22222">/* Decode OS/2 1.x header (Microsoft calls this a BITMAPCOREHEADER) */</FONT></I>
<span class="lineNum">     286 </span><span class="lineCov">              42:     biWidth = (INT32) GET_2B(bmpinfoheader,4);</span>
<span class="lineNum">     287 </span><span class="lineCov">              42:     biHeight = (INT32) GET_2B(bmpinfoheader,6);</span>
<span class="lineNum">     288 </span><span class="lineCov">              42:     biPlanes = GET_2B(bmpinfoheader,8);</span>
<span class="lineNum">     289 </span><span class="lineCov">              42:     source-&gt;bits_per_pixel = (<B><FONT COLOR="#228B22">int</FONT></B>) GET_2B(bmpinfoheader,10);</span>
<span class="lineNum">     290 </span>                : 
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">              14: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">              14: branch 1 taken</span>
<span class="lineNum">         </span><span class="branchTaken">              14: branch 2 taken</span>
</span><span class="lineNum">     291 </span><span class="lineCov">              42:     <B><FONT COLOR="#A020F0">switch</FONT></B> (source-&gt;bits_per_pixel) {</span>
<span class="lineNum">     292 </span>                :     <B><FONT COLOR="#A020F0">case</FONT></B> <B><FONT COLOR="#5F9EA0">8</FONT></B>:			<I><FONT COLOR="#B22222">/* colormapped image */</FONT></I>
<span class="lineNum">     293 </span><span class="lineCov">              14:       mapentrysize = 3;		<I><FONT COLOR="#B22222">/* OS/2 uses RGBTRIPLE colormap */</FONT></I></span>
<span class="lineNum">     294 </span><span class="lineCov">              14:       TRACEMS2(cinfo, 1, JTRC_BMP_OS2_MAPPED, (<B><FONT COLOR="#228B22">int</FONT></B>) biWidth, (<B><FONT COLOR="#228B22">int</FONT></B>) biHeight);</span>
<span class="lineNum">     295 </span><span class="lineCov">              14:       <B><FONT COLOR="#A020F0">break</FONT></B>;</span>
<span class="lineNum">     296 </span>                :     <B><FONT COLOR="#A020F0">case</FONT></B> <B><FONT COLOR="#5F9EA0">24</FONT></B>:			<I><FONT COLOR="#B22222">/* RGB image */</FONT></I>
<span class="lineNum">     297 </span><span class="lineCov">              14:       TRACEMS2(cinfo, 1, JTRC_BMP_OS2, (<B><FONT COLOR="#228B22">int</FONT></B>) biWidth, (<B><FONT COLOR="#228B22">int</FONT></B>) biHeight);</span>
<span class="lineNum">     298 </span><span class="lineCov">              14:       <B><FONT COLOR="#A020F0">break</FONT></B>;</span>
<span class="lineNum">     299 </span>                :     <B><FONT COLOR="#5F9EA0">default</FONT></B>:
<span class="lineNum">     300 </span><span class="lineCov">              14:       ERREXIT(cinfo, JERR_BMP_BADDEPTH);</span>
<span class="lineNum">     301 </span><span class="lineNoCov">               0:       <B><FONT COLOR="#A020F0">break</FONT></B>;</span>
<span class="lineNum">     302 </span>                :     }
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">              28: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchNotTaken">               0: branch 1 not taken</span>
</span><span class="lineNum">     303 </span><span class="lineCov">              28:     <B><FONT COLOR="#A020F0">if</FONT></B> (biPlanes != 1)</span>
<span class="lineNum">     304 </span><span class="lineCov">              28:       ERREXIT(cinfo, JERR_BMP_BADPLANES);</span>
<span class="lineNum">     305 </span><span class="lineNoCov">               0:     <B><FONT COLOR="#A020F0">break</FONT></B>;</span>
<span class="lineNum">     306 </span>                :   <B><FONT COLOR="#A020F0">case</FONT></B> <B><FONT COLOR="#5F9EA0">40</FONT></B>:
<span class="lineNum">     307 </span>                :   <B><FONT COLOR="#A020F0">case</FONT></B> <B><FONT COLOR="#5F9EA0">64</FONT></B>:
<span class="lineNum">     308 </span>                :     <I><FONT COLOR="#B22222">/* Decode Windows 3.x header (Microsoft calls this a BITMAPINFOHEADER) */</FONT></I>
<span class="lineNum">     309 </span>                :     <I><FONT COLOR="#B22222">/* or OS/2 2.x header, which has additional fields that we ignore */</FONT></I>
<span class="lineNum">     310 </span><span class="lineCov">             380:     biWidth = GET_4B(bmpinfoheader,4);</span>
<span class="lineNum">     311 </span><span class="lineCov">             380:     biHeight = GET_4B(bmpinfoheader,8);</span>
<span class="lineNum">     312 </span><span class="lineCov">             380:     biPlanes = GET_2B(bmpinfoheader,12);</span>
<span class="lineNum">     313 </span><span class="lineCov">             380:     source-&gt;bits_per_pixel = (<B><FONT COLOR="#228B22">int</FONT></B>) GET_2B(bmpinfoheader,14);</span>
<span class="lineNum">     314 </span><span class="lineCov">             380:     biCompression = GET_4B(bmpinfoheader,16);</span>
<span class="lineNum">     315 </span><span class="lineCov">             380:     biXPelsPerMeter = GET_4B(bmpinfoheader,24);</span>
<span class="lineNum">     316 </span><span class="lineCov">             380:     biYPelsPerMeter = GET_4B(bmpinfoheader,28);</span>
<span class="lineNum">     317 </span><span class="lineCov">             380:     biClrUsed = GET_4B(bmpinfoheader,32);</span>
<span class="lineNum">     318 </span>                :     <I><FONT COLOR="#B22222">/* biSizeImage, biClrImportant fields are ignored */</FONT></I>
<span class="lineNum">     319 </span>                : 
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">             180: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">             172: branch 1 taken</span>
<span class="lineNum">         </span><span class="branchTaken">              28: branch 2 taken</span>
</span><span class="lineNum">     320 </span><span class="lineCov">             380:     <B><FONT COLOR="#A020F0">switch</FONT></B> (source-&gt;bits_per_pixel) {</span>
<span class="lineNum">     321 </span>                :     <B><FONT COLOR="#A020F0">case</FONT></B> <B><FONT COLOR="#5F9EA0">8</FONT></B>:			<I><FONT COLOR="#B22222">/* colormapped image */</FONT></I>
<span class="lineNum">     322 </span><span class="lineCov">             180:       mapentrysize = 4;		<I><FONT COLOR="#B22222">/* Windows uses RGBQUAD colormap */</FONT></I></span>
<span class="lineNum">     323 </span><span class="lineCov">             180:       TRACEMS2(cinfo, 1, JTRC_BMP_MAPPED, (<B><FONT COLOR="#228B22">int</FONT></B>) biWidth, (<B><FONT COLOR="#228B22">int</FONT></B>) biHeight);</span>
<span class="lineNum">     324 </span><span class="lineCov">             180:       <B><FONT COLOR="#A020F0">break</FONT></B>;</span>
<span class="lineNum">     325 </span>                :     <B><FONT COLOR="#A020F0">case</FONT></B> <B><FONT COLOR="#5F9EA0">24</FONT></B>:			<I><FONT COLOR="#B22222">/* RGB image */</FONT></I>
<span class="lineNum">     326 </span><span class="lineCov">             172:       TRACEMS2(cinfo, 1, JTRC_BMP, (<B><FONT COLOR="#228B22">int</FONT></B>) biWidth, (<B><FONT COLOR="#228B22">int</FONT></B>) biHeight);</span>
<span class="lineNum">     327 </span><span class="lineCov">             172:       <B><FONT COLOR="#A020F0">break</FONT></B>;</span>
<span class="lineNum">     328 </span>                :     <B><FONT COLOR="#5F9EA0">default</FONT></B>:
<span class="lineNum">     329 </span><span class="lineCov">              28:       ERREXIT(cinfo, JERR_BMP_BADDEPTH);</span>
<span class="lineNum">     330 </span><span class="lineNoCov">               0:       <B><FONT COLOR="#A020F0">break</FONT></B>;</span>
<span class="lineNum">     331 </span>                :     }
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">              28: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">             324: branch 1 taken</span>
</span><span class="lineNum">     332 </span><span class="lineCov">             352:     <B><FONT COLOR="#A020F0">if</FONT></B> (biPlanes != 1)</span>
<span class="lineNum">     333 </span><span class="lineCov">              28:       ERREXIT(cinfo, JERR_BMP_BADPLANES);</span>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">              14: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">             310: branch 1 taken</span>
</span><span class="lineNum">     334 </span><span class="lineCov">             324:     <B><FONT COLOR="#A020F0">if</FONT></B> (biCompression != 0)</span>
<span class="lineNum">     335 </span><span class="lineCov">              14:       ERREXIT(cinfo, JERR_BMP_COMPRESSED);</span>
<span class="lineNum">     336 </span>                : 
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">             295: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">              15: branch 1 taken</span>
<span class="lineNum">         </span><span class="branchTaken">             189: branch 2 taken</span>
<span class="lineNum">         </span><span class="branchTaken">             106: branch 3 taken</span>
</span><span class="lineNum">     337 </span><span class="lineCov">             310:     <B><FONT COLOR="#A020F0">if</FONT></B> (biXPelsPerMeter &gt; 0 &amp;&amp; biYPelsPerMeter &gt; 0) {</span>
<span class="lineNum">     338 </span>                :       <I><FONT COLOR="#B22222">/* Set JFIF density parameters from the BMP data */</FONT></I>
<span class="lineNum">     339 </span><span class="lineCov">             189:       cinfo-&gt;X_density = (UINT16) (biXPelsPerMeter/100); <I><FONT COLOR="#B22222">/* 100 cm per meter */</FONT></I></span>
<span class="lineNum">     340 </span><span class="lineCov">             189:       cinfo-&gt;Y_density = (UINT16) (biYPelsPerMeter/100);</span>
<span class="lineNum">     341 </span><span class="lineCov">             189:       cinfo-&gt;density_unit = 2;	<I><FONT COLOR="#B22222">/* dots/cm */</FONT></I></span>
<span class="lineNum">     342 </span>                :     }
<span class="lineNum">     343 </span><span class="lineCov">             310:     <B><FONT COLOR="#A020F0">break</FONT></B>;</span>
<span class="lineNum">     344 </span>                :   <B><FONT COLOR="#5F9EA0">default</FONT></B>:
<span class="lineNum">     345 </span><span class="lineCov">              14:     ERREXIT(cinfo, JERR_BMP_BADHEADER);</span>
<span class="lineNum">     346 </span><span class="lineNoCov">               0:     <B><FONT COLOR="#A020F0">break</FONT></B>;</span>
<span class="lineNum">     347 </span>                :   }
<span class="lineNum">     348 </span>                : 
<span class="lineNum">     349 </span>                :   <I><FONT COLOR="#B22222">/* Compute distance to bitmap data --- will adjust for colormap below */</FONT></I>
<span class="lineNum">     350 </span><span class="lineCov">             310:   bPad = bfOffBits - (headerSize + 14);</span>
<span class="lineNum">     351 </span>                : 
<span class="lineNum">     352 </span>                :   <I><FONT COLOR="#B22222">/* Read the colormap, if any */</FONT></I>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">             166: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">             144: branch 1 taken</span>
</span><span class="lineNum">     353 </span><span class="lineCov">             310:   <B><FONT COLOR="#A020F0">if</FONT></B> (mapentrysize &gt; 0) {</span>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">              49: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">             117: branch 1 taken</span>
</span><span class="lineNum">     354 </span><span class="lineCov">             166:     <B><FONT COLOR="#A020F0">if</FONT></B> (biClrUsed &lt;= 0)</span>
<span class="lineNum">     355 </span><span class="lineCov">              49:       biClrUsed = 256;		<I><FONT COLOR="#B22222">/* assume it's 256 */</FONT></I></span>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">              14: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">             103: branch 1 taken</span>
</span><span class="lineNum">     356 </span><span class="lineCov">             117:     <B><FONT COLOR="#A020F0">else</FONT></B> <B><FONT COLOR="#A020F0">if</FONT></B> (biClrUsed &gt; 256)</span>
<span class="lineNum">     357 </span><span class="lineCov">              14:       ERREXIT(cinfo, JERR_BMP_BADCMAP);</span>
<span class="lineNum">     358 </span>                :     <I><FONT COLOR="#B22222">/* Allocate space to store the colormap */</FONT></I>
<span class="lineNum">     359 </span><span class="lineCov">             304:     source-&gt;colormap = (*cinfo-&gt;mem-&gt;alloc_sarray)</span>
<span class="lineNum">     360 </span><span class="lineCov">             152:       ((j_common_ptr) cinfo, JPOOL_IMAGE,</span>
<span class="lineNum">     361 </span>                :        (JDIMENSION) biClrUsed, (JDIMENSION) 3);
<span class="lineNum">     362 </span>                :     <I><FONT COLOR="#B22222">/* and read it from the file */</FONT></I>
<span class="lineNum">     363 </span><span class="lineCov">             152:     read_colormap(source, (<B><FONT COLOR="#228B22">int</FONT></B>) biClrUsed, mapentrysize);</span>
<span class="lineNum">     364 </span>                :     <I><FONT COLOR="#B22222">/* account for size of colormap */</FONT></I>
<span class="lineNum">     365 </span><span class="lineCov">              14:     bPad -= biClrUsed * mapentrysize;</span>
<span class="lineNum">     366 </span>                :   }
<span class="lineNum">     367 </span>                : 
<span class="lineNum">     368 </span>                :   <I><FONT COLOR="#B22222">/* Skip any remaining pad bytes */</FONT></I>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">              14: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">             144: branch 1 taken</span>
</span><span class="lineNum">     369 </span><span class="lineCov">             158:   <B><FONT COLOR="#A020F0">if</FONT></B> (bPad &lt; 0)			<I><FONT COLOR="#B22222">/* incorrect bfOffBits value? */</FONT></I></span>
<span class="lineNum">     370 </span><span class="lineCov">              14:     ERREXIT(cinfo, JERR_BMP_BADHEADER);</span>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">            3524: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchNotTaken">               0: branch 1 not taken</span>
</span><span class="lineNum">     371 </span><span class="lineCov">            3668:   <B><FONT COLOR="#A020F0">while</FONT></B> (--bPad &gt;= 0) {</span>
<span class="lineNum">     372 </span><span class="lineCov">            3524:     (<B><FONT COLOR="#228B22">void</FONT></B>) read_byte(source);</span>
<span class="lineNum">     373 </span>                :   }
<span class="lineNum">     374 </span>                : 
<span class="lineNum">     375 </span>                :   <I><FONT COLOR="#B22222">/* Compute row width in file, including padding to 4-byte boundary */</FONT></I>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchNotTaken">               0: branch 0 not taken</span>
<span class="lineNum">         </span><span class="branchNotTaken">               0: branch 1 not taken</span>
</span><span class="lineNum">     376 </span><span class="lineNoCov">               0:   <B><FONT COLOR="#A020F0">if</FONT></B> (source-&gt;bits_per_pixel == 24)</span>
<span class="lineNum">     377 </span><span class="lineNoCov">               0:     row_width = (JDIMENSION) (biWidth * 3);</span>
<span class="lineNum">     378 </span>                :   <B><FONT COLOR="#A020F0">else</FONT></B>
<span class="lineNum">     379 </span><span class="lineNoCov">               0:     row_width = (JDIMENSION) biWidth;</span>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchNotTaken">               0: branch 0 not taken</span>
<span class="lineNum">         </span><span class="branchNotTaken">               0: branch 1 not taken</span>
</span><span class="lineNum">     380 </span><span class="lineNoCov">               0:   <B><FONT COLOR="#A020F0">while</FONT></B> ((row_width &amp; 3) != 0) row_width++;</span>
<span class="lineNum">     381 </span><span class="lineNoCov">               0:   source-&gt;row_width = row_width;</span>
<span class="lineNum">     382 </span>                : 
<span class="lineNum">     383 </span>                :   <I><FONT COLOR="#B22222">/* Allocate space for inversion array, prepare for preload pass */</FONT></I>
<span class="lineNum">     384 </span><span class="lineNoCov">               0:   source-&gt;whole_image = (*cinfo-&gt;mem-&gt;request_virt_sarray)</span>
<span class="lineNum">     385 </span><span class="lineNoCov">               0:     ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,</span>
<span class="lineNum">     386 </span>                :      row_width, (JDIMENSION) biHeight, (JDIMENSION) 1);
<span class="lineNum">     387 </span><span class="lineNoCov">               0:   source-&gt;pub.get_pixel_rows = preload_image;</span>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchNotTaken">               0: branch 0 not taken</span>
<span class="lineNum">         </span><span class="branchNotTaken">               0: branch 1 not taken</span>
</span><span class="lineNum">     388 </span><span class="lineNoCov">               0:   <B><FONT COLOR="#A020F0">if</FONT></B> (cinfo-&gt;progress != NULL) {</span>
<span class="lineNum">     389 </span><span class="lineNoCov">               0:     cd_progress_ptr progress = (cd_progress_ptr) cinfo-&gt;progress;</span>
<span class="lineNum">     390 </span><span class="lineNoCov">               0:     progress-&gt;total_extra_passes++; <I><FONT COLOR="#B22222">/* count file input as separate pass */</FONT></I></span>
<span class="lineNum">     391 </span>                :   }
<span class="lineNum">     392 </span>                : 
<span class="lineNum">     393 </span>                :   <I><FONT COLOR="#B22222">/* Allocate one-row buffer for returned data */</FONT></I>
<span class="lineNum">     394 </span><span class="lineNoCov">               0:   source-&gt;pub.buffer = (*cinfo-&gt;mem-&gt;alloc_sarray)</span>
<span class="lineNum">     395 </span><span class="lineNoCov">               0:     ((j_common_ptr) cinfo, JPOOL_IMAGE,</span>
<span class="lineNum">     396 </span>                :      (JDIMENSION) (biWidth * 3), (JDIMENSION) 1);
<span class="lineNum">     397 </span><span class="lineNoCov">               0:   source-&gt;pub.buffer_height = 1;</span>
<span class="lineNum">     398 </span>                : 
<span class="lineNum">     399 </span><span class="lineNoCov">               0:   cinfo-&gt;in_color_space = JCS_RGB;</span>
<span class="lineNum">     400 </span><span class="lineNoCov">               0:   cinfo-&gt;input_components = 3;</span>
<span class="lineNum">     401 </span><span class="lineNoCov">               0:   cinfo-&gt;data_precision = 8;</span>
<span class="lineNum">     402 </span><span class="lineNoCov">               0:   cinfo-&gt;image_width = (JDIMENSION) biWidth;</span>
<span class="lineNum">     403 </span><span class="lineNoCov">               0:   cinfo-&gt;image_height = (JDIMENSION) biHeight;</span>
<span class="lineNum">     404 </span><span class="lineNoCov">               0: }</span>
<span class="lineNum">     405 </span>                : 
<span class="lineNum">     406 </span>                : 
<span class="lineNum">     407 </span>                : <I><FONT COLOR="#B22222">/*
<span class="lineNum">     408 </span>                :  * Finish up at the end of the file.
<span class="lineNum">     409 </span>                :  */</FONT></I>
<span class="lineNum">     410 </span>                : 
<span class="lineNum">     411 </span>                : <B><FONT COLOR="#0000FF">METHODDEF</FONT></B>(<B><FONT COLOR="#228B22">void</FONT></B>)
<span class="lineNum">     412 </span><span class="lineNoCov">               0: <B><FONT COLOR="#0000FF">finish_input_bmp</FONT></B> (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)</span>
<span class="lineNum">     413 </span>                : {
<span class="lineNum">     414 </span>                :   <I><FONT COLOR="#B22222">/* no work */</FONT></I>
<span class="lineNum">     415 </span><span class="lineNoCov">               0: }</span>
<span class="lineNum">     416 </span>                : 
<span class="lineNum">     417 </span>                : 
<span class="lineNum">     418 </span>                : <I><FONT COLOR="#B22222">/*
<span class="lineNum">     419 </span>                :  * The module selection routine for BMP format input.
<span class="lineNum">     420 </span>                :  */</FONT></I>
<span class="lineNum">     421 </span>                : 
<span class="lineNum">     422 </span>                : <B><FONT COLOR="#0000FF">GLOBAL</FONT></B>(cjpeg_source_ptr)
<span class="lineNum">     423 </span><span class="lineCov">             506: <B><FONT COLOR="#0000FF">jinit_read_bmp</FONT></B> (j_compress_ptr cinfo)</span>
<span class="lineNum">     424 </span>                : {
<span class="lineNum">     425 </span>                :   bmp_source_ptr source;
<span class="lineNum">     426 </span>                : 
<span class="lineNum">     427 </span>                :   <I><FONT COLOR="#B22222">/* Create module interface object */</FONT></I>
<span class="lineNum">     428 </span><span class="lineCov">             506:   source = (bmp_source_ptr)</span>
<span class="lineNum">     429 </span><span class="lineCov">             506:       (*cinfo-&gt;mem-&gt;alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,</span>
<span class="lineNum">     430 </span>                : 				  SIZEOF(bmp_source_struct));
<span class="lineNum">     431 </span><span class="lineCov">             506:   source-&gt;cinfo = cinfo;	<I><FONT COLOR="#B22222">/* make back link for subroutines */</FONT></I></span>
<span class="lineNum">     432 </span>                :   <I><FONT COLOR="#B22222">/* Fill in method ptrs, except get_pixel_rows which start_input sets */</FONT></I>
<span class="lineNum">     433 </span><span class="lineCov">             506:   source-&gt;pub.start_input = start_input_bmp;</span>
<span class="lineNum">     434 </span><span class="lineCov">             506:   source-&gt;pub.finish_input = finish_input_bmp;</span>
<span class="lineNum">     435 </span>                : 
<span class="lineNum">     436 </span><span class="lineCov">             506:   <B><FONT COLOR="#A020F0">return</FONT></B> (cjpeg_source_ptr) source;</span>
<span class="lineNum">     437 </span>                : }
<span class="lineNum">     438 </span>                : 
<span class="lineNum">     439 </span>                : #<B><FONT COLOR="#5F9EA0">endif</FONT></B> <I><FONT COLOR="#B22222">/* BMP_SUPPORTED */</FONT></I>
</pre>
<hr>
Generated: 2016-04-07&nbsp;17:52 by <a href="http://minormatter.com/zcov">zcov</a><br>
</body>
</html>
